package cn.ll.po;

import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

/**
 * A data access object (DAO) providing persistence and search support for Bills
 * entities. Transaction control of the save(), update() and delete() operations
 * can directly support Spring container-managed transactions or they can be
 * augmented to handle user-managed Spring transactions. Each of these methods
 * provides additional information for how to configure it for the desired type
 * of transaction control.
 * 
 * @see cn.ll.po.Bills
 * @author MyEclipse Persistence Tools
 */

public class BillsDAO extends HibernateDaoSupport {
	private static final Log log = LogFactory.getLog(BillsDAO.class);
	// property constants
	public static final String CUSTOMERID = "customerid";
	public static final String CUSTOMERNAME = "customername";
	public static final String USERID = "userid";
	public static final String USER_NAME = "userName";
	public static final String STATUS = "status";
	public static final String VERIFYUSER = "verifyuser";
	public static final String PRONAME = "proname";
	public static final String REGION = "region";
	public static final String COUNTRY = "country";
	public static final String CITY = "city";
	public static final String SIZE = "size";
	public static final String CURRENCY = "currency";
	public static final String TYPE = "type";
	public static final String ROOTID = "rootid";
	public static final String COST = "cost";
	public static final String COST_RMB = "costRmb";
	public static final String REQUIREMENTS = "requirements";
	public static final String CONNECTERID = "connecterid";
	public static final String CONNECTERNAME = "connectername";
	public static final String CONTRACTID = "contractid";
	public static final String RECEIPT = "receipt";
	public static final String BILL_MONEY = "billMoney";

	protected void initDao() {
		// do nothing
	}

	public void save(Bills transientInstance) {
		log.debug("saving Bills instance");
		try {
			getHibernateTemplate().save(transientInstance);
			log.debug("save successful");
		} catch (RuntimeException re) {
			log.error("save failed", re);
			throw re;
		}
	}

	public void delete(Bills persistentInstance) {
		log.debug("deleting Bills instance");
		try {
			getHibernateTemplate().delete(persistentInstance);
			log.debug("delete successful");
		} catch (RuntimeException re) {
			log.error("delete failed", re);
			throw re;
		}
	}

	public Bills findById(java.lang.String id) {
		log.debug("getting Bills instance with id: " + id);
		try {
			Bills instance = (Bills) getHibernateTemplate().get("cn.ll.po.Bills", id);
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	public List<Bills> findByExample(Bills instance) {
		log.debug("finding Bills instance by example");
		try {
			List<Bills> results = (List<Bills>) getHibernateTemplate().findByExample(instance);
			log.debug("find by example successful, result size: " + results.size());
			return results;
		} catch (RuntimeException re) {
			log.error("find by example failed", re);
			throw re;
		}
	}

	public List findByProperty(String propertyName, Object value) {
		log.debug("finding Bills instance with property: " + propertyName + ", value: " + value);
		try {
			String queryString = "from Bills as model where model." + propertyName + "= ?";
			return getHibernateTemplate().find(queryString, value);
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}

	public List<Bills> findByCustomerid(Object customerid) {
		return findByProperty(CUSTOMERID, customerid);
	}

	public List<Bills> findByCustomername(Object customername) {
		return findByProperty(CUSTOMERNAME, customername);
	}

	public List<Bills> findByUserid(Object userid) {
		return findByProperty(USERID, userid);
	}

	public List<Bills> findByUserName(Object userName) {
		return findByProperty(USER_NAME, userName);
	}

	public List<Bills> findByStatus(Object status) {
		return findByProperty(STATUS, status);
	}

	public List<Bills> findByVerifyuser(Object verifyuser) {
		return findByProperty(VERIFYUSER, verifyuser);
	}

	public List<Bills> findByProname(Object proname) {
		return findByProperty(PRONAME, proname);
	}

	public List<Bills> findByRegion(Object region) {
		return findByProperty(REGION, region);
	}

	public List<Bills> findByCountry(Object country) {
		return findByProperty(COUNTRY, country);
	}

	public List<Bills> findByCity(Object city) {
		return findByProperty(CITY, city);
	}

	public List<Bills> findBySize(Object size) {
		return findByProperty(SIZE, size);
	}

	public List<Bills> findByCurrency(Object currency) {
		return findByProperty(CURRENCY, currency);
	}

	public List<Bills> findByType(Object type) {
		return findByProperty(TYPE, type);
	}

	public List<Bills> findByRootid(Object rootid) {
		return findByProperty(ROOTID, rootid);
	}

	public List<Bills> findByCost(Object cost) {
		return findByProperty(COST, cost);
	}

	public List<Bills> findByCostRmb(Object costRmb) {
		return findByProperty(COST_RMB, costRmb);
	}

	public List<Bills> findByRequirements(Object requirements) {
		return findByProperty(REQUIREMENTS, requirements);
	}

	public List<Bills> findByConnecterid(Object connecterid) {
		return findByProperty(CONNECTERID, connecterid);
	}

	public List<Bills> findByConnectername(Object connectername) {
		return findByProperty(CONNECTERNAME, connectername);
	}

	public List<Bills> findByContractid(Object contractid) {
		return findByProperty(CONTRACTID, contractid);
	}

	public List<Bills> findByReceipt(Object receipt) {
		return findByProperty(RECEIPT, receipt);
	}

	public List<Bills> findByBillMoney(Object billMoney) {
		return findByProperty(BILL_MONEY, billMoney);
	}

	public List findAll() {
		log.debug("finding all Bills instances");
		try {
			String queryString = "from Bills";
			return getHibernateTemplate().find(queryString);
		} catch (RuntimeException re) {
			log.error("find all failed", re);
			throw re;
		}
	}

	public Bills merge(Bills detachedInstance) {
		log.debug("merging Bills instance");
		try {
			Bills result = (Bills) getHibernateTemplate().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public void attachDirty(Bills instance) {
		log.debug("attaching dirty Bills instance");
		try {
			getHibernateTemplate().saveOrUpdate(instance);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public void attachClean(Bills instance) {
		log.debug("attaching clean Bills instance");
		try {
			getHibernateTemplate().lock(instance, LockMode.NONE);
			log.debug("attach successful");
		} catch (RuntimeException re) {
			log.error("attach failed", re);
			throw re;
		}
	}

	public static BillsDAO getFromApplicationContext(ApplicationContext ctx) {
		return (BillsDAO) ctx.getBean("BillsDAO");
	}
}